package service.product.productservice;

import entity.Product;
import entity.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


@Component
public interface ProductAPI {


    /**
     * 添加一条商品信息
     *
     * @param product
     * @return ResponseMessage
     */
    @RequestMapping("insertProduct")
    @ResponseBody
    public ResponseMessage insertProduct(@RequestBody Product product);


    /**
     * 异步检查是否重名
     * @param pname
     * @return ResponseMessage
     */
    @RequestMapping("insertPnameCheck")
    @ResponseBody
    public ResponseMessage insertPnameCheck(@RequestParam("String") String pname);


    /**
     * 查询所有加工工艺信息
     * @return ResponseMessage
     */
    @RequestMapping("selectMachining")
    @ResponseBody
    public ResponseMessage selectMachining();



    /**
     * 查询所有供应商的 id 和 公司名称 信息
     * @return ResponseMessage
     */
    @RequestMapping("selectProviderInfo")
    @ResponseBody
    public ResponseMessage selectProviderInfo();


    /**
     * 分页查询商品信息,联表分类表和供应商表
     * @return ResponseMessage
     */
    @RequestMapping("selectInfoByProductCategoryProvider")
    @ResponseBody
    public ResponseMessage selectInfoByProductCategoryProvider(
            @RequestParam(value = "providerId",required = false) String providerId,
            @RequestParam(value = "pname",required = false) String pname,
            @RequestParam(value ="type",required = false) String type,
            @RequestParam(value ="status",defaultValue = "-1") String status,
            @RequestParam(value = "sort",defaultValue = "DESC") String sort,
            @RequestParam(value = "pageNum",defaultValue = "") int pageNum
                                                               );


    /**
     * 通过id查询一条商品信息
     * @param id
     * @return  ResponseMessage
     */
    @RequestMapping("selectProductById")
    @ResponseBody
    public ResponseMessage selectProductById(@RequestParam("id") String id);




    /**
     * 更新一条商品信息
     * @param product
     * @return  ResponseMessage
     */
    @RequestMapping("updateProduct")
    @ResponseBody
    public ResponseMessage updateProduct(@RequestBody Product product);



}
